From 06dd0f9ebd2a061adea6ea96ff196c3b7d26ca8f Mon Sep 17 00:00:00 2001 From: lintondf Date: Tue, 30 Jun 2020 20:07:09 -0400 Subject: [PATCH] Write garmin specific ilinks as gpxx:rpt elements (#598) * Write garmin specific ilinks as gpxx:rpt elements when garminextensions option is specified * incorporate code review comments * comment corrected to reflect element being closed --- gpx.cc | 20 +- reference/gdb-sample-v3-ilinks.gdb | Bin 0 -> 10001 bytes reference/gdb-sample-v3-ilinks.gpx | 698 +++++++++++++++++++++++++++++ testo.d/gpx.test | 4 + 4 files changed, 721 insertions(+), 1 deletion(-) create mode 100644 reference/gdb-sample-v3-ilinks.gdb create mode 100644 reference/gdb-sample-v3-ilinks.gpx diff --git a/gpx.cc b/gpx.cc index 2fc109fff..1300d49a8 100644 --- a/gpx.cc +++ b/gpx.cc @@ -1289,7 +1289,10 @@ void GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_point_type point_type) const { // gpx version we are writing is >= 1.1. + garmin_fs_t* gmsd = (opt_garminext) ? garmin_fs_t::find(waypointp) : nullptr; // only needed if garmin extensions selected + if ((opt_humminbirdext && (WAYPT_HAS(waypointp, depth) || WAYPT_HAS(waypointp, temperature))) || + (opt_garminext && gpxpt_route==point_type && gmsd != nullptr && gmsd->ilinks != nullptr) || (opt_garminext && gpxpt_waypoint==point_type && (WAYPT_HAS(waypointp, proximity) || WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth))) || (opt_garminext && gpxpt_track==point_type && (WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth) || waypointp->heartrate != 0 || waypointp->cadence != 0))) { writer->writeStartElement(QStringLiteral("extensions")); @@ -1325,7 +1328,22 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin } break; case gpxpt_route: - /* we don't have any appropriate data for the children of gpxx:RoutePointExtension */ + if (gmsd != nullptr && gpxpt_route==point_type && gmsd->ilinks != nullptr) { + writer->writeStartElement(QStringLiteral("gpxx:RoutePointExtension")); + garmin_ilink_t* link = gmsd->ilinks; + garmin_ilink_t* prior = nullptr; // GDB files sometime contain repeated point; omit them + while (link != nullptr) { + if (prior == nullptr || prior->lat != link->lat || prior->lon != link->lon) { + writer->writeStartElement(QStringLiteral("gpxx:rpt")); + writer->writeAttribute(QStringLiteral("lat"), toString(link->lat)); + writer->writeAttribute(QStringLiteral("lon"), toString(link->lon)); + writer->writeEndElement(); // "gpxx:rpt" + } + prior = link; + link = link->next; + } + writer->writeEndElement(); // "gpxx:RoutePointExtension" + } break; case gpxpt_track: if (WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth) || waypointp->heartrate != 0 || waypointp->cadence != 0) { diff --git a/reference/gdb-sample-v3-ilinks.gdb b/reference/gdb-sample-v3-ilinks.gdb new file mode 100644 index 0000000000000000000000000000000000000000..d82bab49ab6021067a7b10a1801b44a6463aafbb GIT binary patch literal 10001 zcmchc36K=k8OOibWl{We6V)l|-m&y&H4X=W^D7DbDq5{q6HExsz&P5PHt zB?gq=I!n^1TNaH*W6}&HmyF*U`4*o`E)Y2=mrJh9e!H10+Wx5VQG8*2gjE*2JGhkJ zB2DnWz#{8UWBeVGs5Vncb3#?jEKkPGc)D^lsQA4&Uv+{Blv#l*b-ycW4IIRADew#+QauAJ@sZcLpWH(AK&7wZvCv06f>Lp?I zoAbZS$(7+$fBF$a#w=0lFJE11>jXkJDZ6^NuzHL9k-53j|0vX7e8`aNmnroVS7lZo zlU==gSbavLwTMht`u_YjLr&kP)E_9xtUfEOJ{Lvo)gA%$98(TAS(uwABU4R9dTcSI z+ZtPa!7T$at3L~=@ipnBnXa5ZgJY^XWsWn4q-tiytEQ#WDRXQ*VBhJMo&n=hD08MK z8|6v+Dj46f$&g;FmGO#xnT;-Lq8dl$! z8k&V31ThaTlZ`FCP)Bu{2>NOi6?ldBE6cCAwXpkrqBK4J9~itspKy7f>#)kxHc#S)c4!&%hc52R{?X z>XBh9j1CJn*j5)jKQOaZ7!7{Zq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{LwBl28Zu1%V6ZE`oYz0fk!*fAhjt^A(KSYAZ*jB{g)x zCT1ei&@vEkFJU-f3t<@GQNlHVR|x$8pAd!u{!17SXtWhD4Zs|xBms>H^8u$==T5*e z!ZJWTVH4o@guQ^L2%iF$63)er?+!wHz+A#8z!buZfGFV%055*fM3QCIX^$^N8IGQw z*GCKy-y^vpvgREvuAvQf!57k8UqAG~Gch+48Yg%b{yB05-vq&P= zhu19_r`dh--`M`?&q{MTFS+2Y%$!QM2Y+lxRsgl literal 0 HcmV?d00001 diff --git a/reference/gdb-sample-v3-ilinks.gpx b/reference/gdb-sample-v3-ilinks.gpx new file mode 100644 index 000000000..eb81cd6c7 --- /dev/null +++ b/reference/gdb-sample-v3-ilinks.gpx @@ -0,0 +1,698 @@ + + + + + + + + + Birch Harbor + Birch Harbor + Birch Harbor + City (Small) + + + + Gouldsboro + Gouldsboro + Gouldsboro + City (Small) + + + + Prospect Harbor + Prospect Harbor + Prospect Harbor + City (Small) + + + + Schoodic Woods Campground + Schoodic Woods Campground +Schoodic Loop Rd +Winter Harbor Twn, Maine, 04693, United States +207-288-1300 + Schoodic Woods Campground +Schoodic Loop Rd +Winter Harbor Twn, Maine, 04693, United States +207-288-1300 + Campground + + + + Sullivan Twn + Sullivan Twn + Sullivan Twn + City (Small) + + + Trip to Schoodic Woods Campground - Day 1 + + + false + Magenta + + + + + Sullivan Twn + Sullivan Twn + Sullivan Twn + City (Small) + + + + + + + + + 45.738 + 0001 + Get on Us1 and drive east + [PT6S] + Waypoint + + + + + + + + + 45.563 + 0002 + [PT23S] + Waypoint + + + + + + + + + + + + 44.266 + 0003 + [PT2M3S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + + + 28.781 + 0004 + [PT1M28S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + 26.887 + 0005 + [PT1M21S] + Waypoint + + + + + + + + + + + + + + + + + + + + + 20.605 + 0006 + [PT1M52S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + 38.840 + 0007 + Turn right onto S Gouldsboro Rd + [PT3M4S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 34.777 + 0008 + [PT2M12S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 38.371 + 0009 + [PT3S] + Waypoint + + + + + + + + + 38.293 + 0010 + [PT1M29S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + 36.547 + 0011 + [PT1M11S] + Waypoint + + + + + + + + + + + + + 24.645 + 0012 + [PT1M3S] + Waypoint + + + + + + + + + + + + + 15.426 + 0013 + [PT49S] + Waypoint + + + + + + + + + + + 11.945 + 0014 + [PT1M1S] + Waypoint + + + + + + + + + + + + 9.000 + 0015 + Turn left onto Main St + [PT1M35S] + Waypoint + + + + + + + + + + + + + + + + 15.344 + 0016 + [PT23S] + Waypoint + + + + + + + + + + + + 21.840 + 0017 + Turn right onto Moore Rd + [PT1M37S] + Waypoint + + + + + + + + + + + + + + + + + + 41.480 + 0018 + [PT0S] + Waypoint + + + + + + + + + + Schoodic Woods Campground + Schoodic Woods Campground +Schoodic Loop Rd +Winter Harbor Twn, Maine, 04693, United States +207-288-1300 + Schoodic Woods Campground +Schoodic Loop Rd +Winter Harbor Twn, Maine, 04693, United States +207-288-1300 + Campground + + + + + + + + + 41.480 + 0019 + Get on Moore Rd and drive north + [PT1M16S] + Waypoint + + + + + + + + + + + + + + + + + + 21.840 + 0020 + Turn right onto Birch Harbor Rd + [PT1M13S] + Waypoint + + + + + + + + + + 29.652 + 0021 + [PT1M39S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + 29.453 + 0022 + [PT0S] + Waypoint + + + + + + + + 29.453 + 0023 + [PT0S] + Waypoint + + + + + + + + + + 1 Birch Harbor Rd + 1 Birch Harbor Rd +Winter Harbor, ME, 04693, USA + Flag, Blue + + + + + + + + + 29.453 + 0024 + [PT0S] + Waypoint + + + + + + + + 29.453 + 0025 + [PT41S] + Waypoint + + + + + + + + + + + 22.574 + 0026 + [PT1M29S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + 13.723 + 0027 + [PT2M28S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 13.098 + 0028 + [PT20S] + Waypoint + + + + + + + + + + + 12.836 + 0029 + [PT18S] + Waypoint + + + + + + + + + 12.707 + 0030 + [PT0S] + Waypoint + + + + + + + + + + Prospect Harbor + Prospect Harbor + Prospect Harbor + City (Small) + + + diff --git a/testo.d/gpx.test b/testo.d/gpx.test index 19ca6c83b..16afe9f6a 100644 --- a/testo.d/gpx.test +++ b/testo.d/gpx.test @@ -54,3 +54,7 @@ compare ${REFERENCE}/global.gpx ${TMPDIR}/global.gpx rm -f ${TMPDIR}/metadata.gpx gpsbabel -i gpx -f ${REFERENCE}/metadata.gpx -o gpx -F ${TMPDIR}/metadata.gpx compare ${REFERENCE}/metadata~gpx.gpx ${TMPDIR}/metadata.gpx + +# output ilinks if gpx garamextensions specified +gpsbabel -i gdb,dropwpt -f ${REFERENCE}/gdb-sample-v3-ilinks.gdb -o gpx,garminextensions -F ${TMPDIR}/gdb-sample-v3-ilinks.gpx +compare ${REFERENCE}/gdb-sample-v3-ilinks.gpx ${TMPDIR}/gdb-sample-v3-ilinks.gpx -- 2.30.2